#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

vector<int> nums;
int main()
{
    int n;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        int w;
        scanf("%d", &w);
        if (w == 0)nums.push_back(i);
    }

    nums.push_back(1e7);

    int r = 0;
    for (int i = 0; i < n; i++)
    {
        while (i > nums[r + 1] && r + 1 < nums.size() - 1)r++;
        cout << min(abs(i - nums[r]), abs(i - nums[r + 1])) << " ";
    }

    return 0;
}